import { actionTypes } from '../store'
import axios from 'axios'

const setData=(username,possword)=>({
    type:actionTypes.LOGIN,
    username,
    possword
});
export const loginTo=(username,possword)=>{
    return(dispatch)=>{
        axios.get('/api/login.json').then((res)=>{
            if(res.data.data){
                dispatch(setData(username,possword))
            }else {
                alert('登录失败')
            }
        }).catch((err)=>{
                console.log(err)
        })
    }
};
export const logout =() => ({
    type:actionTypes.LOGOUT
});




